package javazuoye.one;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/06/27 08:14
 */
public class _2_2_16 {
    static class Node {
        int val;
        int freq = 0;
        Node next;
        Node pre;

        public Node() {
        }

        public Node(int val) {
            this.val = val;
        }
    }

    public Node LRU(Node node, int x) {
        Node deep = node;
        while (deep != null && deep.val != x) {
            deep = deep.next;
        }
        if (deep != null) {
            deep.freq++;
            if (deep.pre == null) {
                return deep;
            }
            deep.pre = deep.next;
            deep.pre = null;
            deep.next = node;
            return deep;
        }
        return null;
    }

}
